﻿using HomagChina.CCHCS.DataTypeModel;
using HomagChina.CCHCS.ViewModels;
using HomagChina.CCHCS.Views;
using HomagGroup.Base.UI;
using HomagGroup.Base.UI.Themes.Resources;
using System.Collections.ObjectModel;
using static HomagChina.CCHCS.ProcessResourceInternal;
using static HomagChina.CCHCS.Utility;

namespace HomagChina.CCHCS.Router
{
    public class StockRoute : NotifyPropertyChangedBase
    {
        public RouterItemDataModel StockRouteModel { get; set; }

        public StockRoute()
        {
            var model = new StockViewModel();
            var userControl = GetUserControlInstance("Stock") as Stock;
            model.RequestScrollPositionSave += userControl.ViewModel_RequestScrollPositionSave;
            model.RequestScrollPositionRestore += userControl.ViewModel_RequestScrollPositionRestore;
            StockRouteModel = new RouterItemDataModel()
            {
                ID = "Stock",
                viewLabel = GetLocalText("Stock"),
                viewName = "Stock",
                viewModelName = "StockViewModel",
                ViewModel = model,
                keepalive = true,
                userControl = GetUserControlInstance("Stock"),
                Image = null,
                functionKeyBarItems = new ObservableCollection<FunctionKeyBarItemDataModel>{
                    //new FunctionKeyBarItemDataModel() {
                    //    Header =GetLocalText("Exit"),
                    //    Position = 12,
                    //    Icon = GetIconBrush(Icon.Close, ImageDecoration.Circle),
                    //    Command = new RelayCommand(() => { Application.Current.Shutdown(); })
                    //},
                    new FunctionKeyBarItemDataModel() {
                        Header =GetLocalText("Refresh"),
                        Position = 10,
                        Icon = GetIconBrush(Icon.Refresh, ImageDecoration.Circle),
                        Command = new RelayCommand(() => { model.Query(); })
                    },
                    new FunctionKeyBarItemDataModel() {
                        Header =GetLocalText("Return to warehouse"),
                        Position = 7,
                        Icon = GetIconBrush(Icon.Refresh, ImageDecoration.Circle),
                        Command = new RelayCommand(() => { model.Return2Warehouse(); })
                    },
                     new FunctionKeyBarItemDataModel() {
                        Header = GetLocalText("Clear"),
                        Position = 6,
                        Icon = GetIconBrush(Icon.Delete, ImageDecoration.Circle),
                        Command = new RelayCommand(() => { model.Delete(); })
                    },
                }
            };
            StockRouteModel.userControl.DataContext = model;
        }
    }
}